package com.aoxin.controller.activity;

import java.util.List;

import com.aoxin.model.activity.SlfRecommendMoneySale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aoxin.model.activity.SlfRecommendMoney;
import com.aoxin.service.inter.activity.RecommendMoneyService;
import com.aoxin.util.AjaxRes;
import com.aoxin.util.Const;
import com.aoxin.util.enumerate.OperateType;
import com.aoxin.util.log.LogInfo;
/**
 *推荐金额接口
 * @author lop
 * @date 2018年4月28日 上午12:14:48
 */
@RestController
@RequestMapping("/web/recommendMoney/")
public class RecommendMoneyController {

	@Autowired
	RecommendMoneyService recommendMoneyService;


	/**
	 * 查询推荐金额数据
	 * @param res
	 * @param slfRecommendMoney
	 * @return
	 */
	@RequestMapping("getRecommendMoney")
	@LogInfo(operateType = OperateType.QUERY, content = "查询推荐金额数据")
	public AjaxRes getRecommendMoney(AjaxRes res,SlfRecommendMoney slfRecommendMoney){
		try {
			List<SlfRecommendMoney> slfRecommendMoneyS=this.recommendMoneyService.getRecommendMoney(slfRecommendMoney);  
			res.setSucceed(slfRecommendMoneyS, Const.DATA_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
	
	/**
	 * 推荐金额数据
	 * @param res
	 * @param slfRecommendMoney
	 * @return
	 */
	@RequestMapping("insertRecommendMoney")
	@LogInfo(operateType = OperateType.INSERT, content = "添加推荐金额表数据")
	public AjaxRes insertRecommendMoney(AjaxRes res,SlfRecommendMoney slfRecommendMoney){
		try {
			
			this.recommendMoneyService.insertRecommendMoney(slfRecommendMoney);  
			res.setSucceedMsg(Const.SAVE_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
	/**
	 * 更新推荐金额
	 * @param res
	 * @param slfRecommendMoney
	 * @return
	 */
	@RequestMapping("updateRecommendMoney")
	@LogInfo(operateType = OperateType.UPDATE, content = "更新推荐金额")
	public AjaxRes updateRecommendMoney(AjaxRes res,SlfRecommendMoney slfRecommendMoney,Integer type){
		try {
		SlfRecommendMoney superSlfRecommendMoney=this.recommendMoneyService.updateRecommendMoney(slfRecommendMoney,type);  
		res.setSucceed(superSlfRecommendMoney, Const.UPDATE_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
	
	/**
	 * 更新提现标志
	 * @param res
	 * @param isWithdraw
	 * @return
	 */
	@RequestMapping("updateIsWithdraw")
	@LogInfo(operateType = OperateType.UPDATE, content = "更新提现标志")
	public AjaxRes updateIsWithdraw(AjaxRes res,Integer cashId,Integer userId,Integer isWithdraw,Integer cashType){
		try {
		Integer integer=this.recommendMoneyService.updateIsWithdraw(cashId,userId,isWithdraw,cashType);  
		res.setSucceed(integer);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}

	/**
	 * 查询有效推广人数
	 * @param res
	 * @return
	 */
	@RequestMapping("effectiveNumber")
	public AjaxRes effectiveNumber(AjaxRes res){
		try {
		List<Integer> integer=this.recommendMoneyService.effectiveNumber();
		res.setSucceed(integer, Const.DATA_SUCCEED);
	} catch (Exception e) {
		res.setFailMsg(e.getMessage());
	}
		return res;
	}

	/**
	 * 查询销售推荐人与被推荐人关系数据
	 * @param res
	 * @param slfRecommendMoneySale
	 * @return
	 */
	@RequestMapping("queryRecommendMoneySale")
	public AjaxRes queryRecommendMoneySale(AjaxRes res,SlfRecommendMoneySale slfRecommendMoneySale){
		try {
			List<SlfRecommendMoneySale> list=this.recommendMoneyService.queryRecommendMoneySale(slfRecommendMoneySale);
			res.setSucceed(list, Const.DATA_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
}
